package cn.gemiman.daoyi.module.cms.controller.admin.blogtalk.vo;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.List;

@Schema(description = "管理后台 - 说说新增/修改 Request VO")
@Data
public class BlogTalkSaveReqVO {

    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6518")
    private Long id;

    @Schema(description = "用户类型", example = "2")
    private Integer userType;

    @Schema(description = "用户编号", example = "23520")
    private Long userId;

    @Schema(description = "用户昵称", example = "道一")
    private String userNickname;

    @Schema(description = "用户头像")
    private String userAvatar;

    @Schema(description = "站点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8099")
    @NotNull(message = "站点编号不能为空")
    private Long appSiteId;

    @Schema(description = "站点标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "21134")
    @NotEmpty(message = "站点标识不能为空")
    private String appId;

    @Schema(description = "图片")
    private List<String> talkImgList;

    @Schema(description = "视频")
    private String talkVideo;

    @Schema(description = "内容")
    private String content;

    @Schema(description = "@谁")
    private String referTo;

    @Schema(description = "状态", example = "1")
    private Integer status;

    @Schema(description = "审核状态", example = "1")
    private Integer approveStatus;

    @Schema(description = "排序")
    private Long sort;

    @Schema(description = "访问次数")
    private Long viewTimes;

    @Schema(description = "点赞数量")
    private Long thumbsUpTimes;

    @Schema(description = "创建者ip")
    private String creatorIp;

    @Schema(description = "创建者城市")
    private String creatorCity;

    @AssertTrue(message = "图片、文字、视频不能同时为空")
    public boolean isImgOrVideoNotEmpty() {
        return CollUtil.isNotEmpty(talkImgList) || CharSequenceUtil.isNotBlank(talkVideo) || CharSequenceUtil.isNotBlank(content);
    }
}
